package Server;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User:xieChao
 * Date:2022/11/9 21:24
 */
public class TestDict extends UdpEchoServer{
    private HashMap<String,String> dict = new HashMap<>();
    public TestDict(int port) throws SocketException {
        super(port);

        dict.put("hello","你好");
        dict.put("world","世界");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"该词无法翻译！");
    }

    public static void main(String[] args) throws IOException {
        TestDict testDict = new TestDict(9090);
        testDict.start();
    }
}
